<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>涉外资料表单</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script src='<c:url value="/js/rqfui/rqfui.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body {
	height: 100%;
}

.fieldTitle {
	width: 98px !important;
}

.mini-tabs-leftButton, .mini-tabs-rightButton {
	display: none;
}

.mini-tabs-scrollCt {
	border-top: 0;
}

.mini-tabs-bodys {
	padding: 0;
}
.headerpan{
	margin-left: 10px;
	font-size: 14px;
	font-weight:bold;
}
</style>
<script type="text/javascript">
 var selectData=[{"text":"机构"},{"text":"个人"}];
 var aimData = [{"text":"留学"},{"text":"务工"},{"text":"旅行"},{"text":"商贸"},{"text":"科技交流"},{"text":"会议"}];
 var sexData = [ {'text':'男'},{'text':'女'}];
</script>
</head>
<body>
	
	<form id="dataForm">
		
		<div class="formContent">
		<input  class="mini-hidden" id="type" name="type" ></input>
			<table class="formContentTable" id="type1">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">国家/地区</td>
					<td class="fieldContent"><input name="country_area"
						required="true" class="mini-combobox" style="width: 100%;"
						textField="zh_name" valueField="zh_name"
						url="<c:url value='/common/country'></c:url>" showNullItem="false"
						allowInput="true" /></td>
					<td class="fieldTitle" >法律法规</td>
					<td class="fieldContent"><input id="area_range" name="laws"
						class="mini-textbox" style="width: 100%;" value="${laws}" /></td>
				</tr>
				<tr>
					<td class="fieldTitle" >国家概况</td>
					<td class="fieldContent" colspan="3"><textarea id="com_org_name"
							name="com_org_name" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${com_org_name}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">紧急救助电话</td>
					<td class="fieldContent" colspan="3"><textarea id="com_org_contact"
							name="com_org_contact" style="width: 100%; height: 50px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${com_org_contact}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">风俗习惯</td>
					<td class="fieldContent" colspan="3"><textarea id="custom"
							name="custom" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${custom}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">宗教信仰</td>
					<td class="fieldContent" colspan="3"><textarea id="faith"
							name="faith" style="width: 100%; height: 50px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${faith}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">政治形势</td>
					<td class="fieldContent" colspan="3"><textarea id="politics"
							name="politics" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${politics}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">民族关系</td>
					<td class="fieldContent" colspan="3"><textarea id="nation_rla"
							name="nation_rla" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${nation_rla}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">医疗卫生</td>
					<td class="fieldContent" colspan="3"><textarea id="health_care"
							name="health_care" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${health_care}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">气候条件</td>
					<td class="fieldContent" colspan="3"><textarea id="climatic_cond"
							name="climatic_cond" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${climatic_cond}"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
			</table>
			<!-- 应急处理流程 -->
			<table class="formContentTable" id="type3">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle" >流程名称</td>
					<td class="fieldContent" colspan="3"><input id="name"
							name="name" style="width: 100%;"
							required="true" class="mini-textbox" 
							value="${name}"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">国家/地区</td>
					<td class="fieldContent" colspan="3"><input name="country_area"
						required="true" class="mini-combobox" style="width: 100%;"
						textField="zh_name" valueField="zh_name"
						url="<c:url value='/common/country'></c:url>" showNullItem="false"
						allowInput="true" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">流程内容</td>
					<td class="fieldContent" colspan="3"><textarea id="content"
							name="content" style="width: 100%; height: 150px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${content}"></textarea></td></td>
				</tr>
				<tr>
					<td class="fieldTitle">流程分类</td>
					<td class="fieldContent" colspan="3"><input id="class"
							name="class1" style="width: 100%;"
							required="true" class="mini-textbox"/>
					</td>
				</tr>
				<tr>
					<td class="fieldTitle">其他说明</td>
					<td class="fieldContent" colspan="3"><textarea id="content"
							name="other_decl" style="width: 100%; height: 150px;"
							required="false" class="mini-textarea" emptyText="无"></textarea></td></td>
				</tr>
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
			</table>
			<!-- 相关专题 -->
			<table class="formContentTable" id="type4">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle" >专题名称</td>
					<td class="fieldContent" colspan="3"><input id="name"
							name="name" style="width: 100%;"
							required="true" class="mini-textbox" 
							value="${name}"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">专题类别</td>
					<td class="fieldContent" colspan="3"><input id="class"
							name="class1" style="width: 100%;"
							required="true" class="mini-textbox"/>
					</td>
				</tr>
				<tr>
					<td class="fieldTitle">专题概述</td>
					<td class="fieldContent" colspan="3"><textarea id="summarize"
							name="summarize" style="width: 100%; height: 150px;"
							required="true" class="mini-textarea" emptyText="无"
							></textarea></td></td>
				</tr>
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
			</table>
			<!-- 涉外机构和人员 -->
			<table class="formContentTable" id="type2">
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr style="display:none !important;">
					<td class="fieldTitle" >机构或个人</td>
					<td class="fieldContent" colspan="3"><input id="org_or_pers" class="mini-combobox"
							name="org_or_pers" style="width: 100%;" 
							textField="text" valueField="text" data="selectData"
							required="true" value="机构"   onvaluechanged="showOrgOrPer()"/>
					</td>
				</tr>
				<tr id="org">
				<table class="formContentTable" id="orgInfo">
					<tr>
					<th class="fieldTitle"><span class="headerpan" >机构信息</span></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					</tr>
					<tr>
						<td class="fieldTitle" >机构名称</td>
						<td class="fieldContent" colspan="3"><input id="org_name"
								name="org_name" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					</tr>
					<tr>
						<td class="fieldTitle">国家/地区</td>
						<td class="fieldContent"><input name="country_area" id="country_area"
							required="true" class="mini-combobox" style="width: 100%;"
							textField="zh_name" valueField="zh_name"
							url="<c:url value='/common/country'></c:url>" showNullItem="false"
							allowInput="false" onvaluechanged="continent" /></td>
						<td class="fieldTitle" >所属区域</td>
						<td class="fieldContent"><input id="area_range" name="area_range"
							class="mini-textbox" style="width: 100%;" allowInput="false" /></td>
					</tr>
					<tr>
						<td class="fieldTitle" >成员构成</td>
						<td class="fieldContent" colspan="3"><textarea id="business_scope"
							name="business_scope" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${business_scope}"></textarea></td>
					</tr>
					<tr>
						<td class="fieldTitle" >机构简介</td>
						<td class="fieldContent" colspan="3"><textarea id="org_nature"
							name="org_nature" style="width: 100%; height: 100px;"
							required="true" class="mini-textarea" emptyText="无"
							value="${org_nature}"></textarea></td>
					</tr>
					<tr style="display:none !important;">
					<td class="fieldTitle" >出行目的</td>
					<td class="fieldContent" colspan="3"><input id="trip_pur"
							name="trip_pur" style="width: 100%;"
							textField="text" valueField="text" data="aimData"
							required="true" class="mini-combobox" />
					</td>
				</tr>
					<tr>
						<td class="fieldTitle" >成立时间</td>
						<td class="fieldContent" colspan="3"><input id="station_time"
								name="station_time" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					</tr>
					<tr style="display:none !important;">
						<td class="fieldTitle" >机构联系人</td>
						<td class="fieldContent" colspan="3"><input id="org_contact"
								name="org_contact" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					</tr>
					<tr>
						<td class="fieldTitle" >联系方式</td>
						<td class="fieldContent" colspan="3"><input id="telephone"
								name="telephone" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					</tr>
					<tr style="display:none !important;">
						<td class="fieldTitle" >联系人邮箱</td>
						<td class="fieldContent" colspan="3"><input id="email"
								name="email" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					</tr>
				</table>
				</tr>
				<tr>
				<table class="formContentTable" id="perInfo">
				<tr>
					<th class="fieldTitle"><span class="headerpan" >个人信息</span></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					</tr>
				 
				<tr>
						<td class="fieldTitle" >姓名</td>
						<td class="fieldContent"><input id="org_name"
								name="name" style="width: 100%;"
								required="true" class="mini-textbox" 
								/></td>
					<td class="fieldTitle" >性别</td>
					<td class="fieldContent"><input id="com_org_name"
							name="sex" style="width: 100%;"
							textField="text" valueField="text" data="sexData"
							required="true" class="mini-combobox" />
					</td>
				</tr>
				<tr>
					<td class="fieldTitle">国家/地区</td>
					<td class="fieldContent"><input name="country_area" id="country_area1"
						required="true" class="mini-combobox" style="width: 100%;"
						textField="zh_name" valueField="zh_name"
						url="<c:url value='/common/country'></c:url>" showNullItem="false"
						allowInput="false"  onvaluechanged="continent1"/></td>
					<td class="fieldTitle" >所属区域</td>
					<td class="fieldContent"><input id="area_range1" name="area_range"
						class="mini-textbox" style="width: 100%;" allowInput="false" /></td>
				</tr>
				<tr>
					<td class="fieldTitle" >身份证号</td>
					<td class="fieldContent" colspan="3"><input id="com_org_name"
							name="idcard" style="width: 100%;"
							required="false" class="mini-textbox" />
					</td>
				</tr>
				<tr>
					<td class="fieldTitle">从事行业</td>
					<td class="fieldContent" colspan="3"><input id="trade"
							name="trade" style="width: 100%;"
							required="true" class="mini-textbox" 
							/></td>
				</tr>
				<tr>
					<td class="fieldTitle">职业</td>
					<td class="fieldContent" colspan="3"><input id="vocation"
							name="vocation" style="width: 100%;"
							required="false" class="mini-textbox" 
							/></td>
				</tr>
				<tr>
					<td class="fieldTitle">工作单位</td>
					<td class="fieldContent" colspan="3"><input id="work_place"
							name="work_place" style="width: 100%;"
							required="true" class="mini-textbox" 
							/></td>
				</tr>
				<tr>
					<td class="fieldTitle" >出行目的</td>
					<td class="fieldContent" colspan="3"><input id="com_org_name"
							name="trip_pur" style="width: 100%;"
							textField="text" valueField="text" data="aimData"
							required="true" class="mini-combobox" />
					</td>
				</tr>
				<tr>
					<td class="fieldTitle">停留时间</td>
					<td class="fieldContent" colspan="3"><input id="remain_time"
							name="remain_time" style="width: 100%;"
							required="false" class="mini-textbox" 
							/></td>
				</tr>
				<tr>
					<td class="fieldTitle">联系电话1</td>
					<td class="fieldContent" colspan="3"><input id="telephone1"
							name="telephone1" style="width: 100%;"
							required="true" class="mini-textbox" 
							/></td>
				</tr>
				<tr>
					<td class="fieldTitle">联系电话2</td>
					<td class="fieldContent" colspan="3"><input id="telephone2"
							name="telephone2" style="width: 100%;"
							required="false" class="mini-textbox" 
							value="${health_care}"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">邮箱地址</td>
					<td class="fieldContent" colspan="3"><input id="email"
							name="email" style="width: 100%;"
							required="true" class="mini-textbox" 
							/></td>
				</tr>
				</table>
				</tr>
				<table class="formContentTable" id="timer" >
				<tr>
					<td class="fieldTitle">编制人</td>
					<td class="fieldContent"><input id="creater" enabled="false"
						name="creater" class="mini-textbox" style="width: 100%;"
						value="${creater}" /></td>
					<td class="fieldTitle">编制日期</td>
					<td class="fieldContent"><input id="createTime" enabled="false"
						name="createTime" class="mini-datepicker" style="width: 100%;"
						value="${createTime}" /></td>
				</tr>
				</table>
			</table>
		</div>
	</form>
	
	
	

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var rootPath = parent.getRootPath();
		var userName = parent.getUserName();
		var action = parent.getAction();
		var type = parent.getType();
		var id = parent.getId();
		var dataOri = null;
		var orgInfo = $("#orgInfo");
		var perInfo = $("#perInfo");
		selectTable();
		if(type && type!="4"){
			if(parent.hideAtt){
				parent.hideAtt();
			}
		}
		var form = new mini.Form("dataForm");
		SetFormData();
		function selectTable(){
			if(type && type=="1"){
				$("#type2").remove();
				$("#type3").remove();
				$("#type4").remove();
				$("#orgInfo").remove();
				$("#timer").remove();
				$("#perInfo").remove();
			}
			if(type && type=="2"){
				$("#type1").remove();
				$("#type3").remove();
				$("#type4").remove();
				$("#perInfo").remove();
			}
			if(type && type=="3"){
				$("#type1").remove();
				$("#type2").remove();
				$("#type4").remove();
				$("#orgInfo").remove();
				$("#timer").remove();
				$("#perInfo").remove();
			}
			if(type && type=="4"){
				$("#type1").remove();
				$("#type3").remove();
				$("#type2").remove();
				$("#orgInfo").remove();
				$("#timer").remove();
				$("#perInfo").remove();
			}
		}
		function SetFormData() {
			if(action == "new"){
				var o = new Object();
				o.creater = userName;
				o.createTime = new Date();
				o.type = type;
				form.setData(o);
				mini.get("org_or_pers").select(0);
				dataOri = o;
				return;
			}
			var messageid = mini.loading("获取中...", "Loading");
			var urlBase = '<c:url value="/foreign/countryForm/"></c:url>'+ id+"/"+type;
			$.ajax({
				url : urlBase,
				type : "get",
				dataType : 'json',
				success : function(text) {
					if (!text) {
						return;
					}
					var o = mini.decode(text);
					o.type = type;
					var amount = o.Amount;
					if (typeof amount == "number") {
						o.Amount = amount.toFixed(2);
					}
					var tAmount = o.TotalAmount;
					if (typeof tAmount == "number") {
						o.TotalAmount = tAmount.toFixed(2);
					}
					var ratio = o.RetentionRatio;
					if (typeof ratio == "number") {
						o.RetentionRatio = ratio.toFixed(2);
					}
					var rAmount = o.RetentionAmount;
					if (typeof rAmount == "number") {
						o.RetentionAmount = rAmount.toFixed(2);
					}
					
					var org_or_pers = o.org_or_pers;
					if(org_or_pers=="机构"){
						$("#org").html(orgInfo);
					}else if(org_or_pers=="个人"){
						$("#org").html(perInfo);
						$("#orgInfo").remove();
					}
					form.setData(o);
					dataOri = o;
					parent.labelModel(form);
				},
				complete : function(XMLHttpRequest, textStatus) {
					mini.hideMessageBox(messageid);
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function packData() {
			return form;
		}

		/* SetFormData();
		loadList();
		loadAttachment();
		parent.hideAttchPan(); */

		/* 加载附件 */
		function loadAttachment() {
			/* grid2.load(rootPath + "attchment/list/" + refNo + "/HTG/" + version);
			grid2.load();
			grid3.load(rootPath + "attchment/list/" + refNo + "/YY/" + version);
			grid3.load(); */
			
			grid2.load(rootPath + "attchment/listall/" + refNo + "/HTG");
			grid2.load({},function(){
				if(grid2.data.length > 0){
					grid2.groupBy("VersionGroup", "desc");
				}
			});
			grid3.load(rootPath + "attchment/listall/" + refNo + "/YY");
			grid3.load({},function(){
				if(grid3.data.length > 0){
					grid3.groupBy("VersionGroup", "desc");
				}
			});
		}

		function loadList() {
			if (version == null || version == "") {
				parent.mini.alert("无法获得数据版本!");
				return;
			}
			var url = '<c:url value="/wsData/ws000011/list/string/"></c:url>'
					+ refNo + "/" + version;
			grid1.load(url);
			grid1.load({}, function() {
				parent.contentFormOnload();
			});
		}

		function onDrawCell(e) {
			var item = e.record, field = e.field, value = e.value;
			if (field == "AttchmntName") {
				var html = "";
				var fileName = e.row.AttchmntName;
				var dotPos = fileName.lastIndexOf(".");
				if (dotPos > 0) {
					var fileType = fileName.substring(dotPos, fileName.length);
					if (typeof fileType != "undefined" && fileType != null) {
						fileType = fileType.toLowerCase();
					}
					switch (fileType) {
					case ".doc":
						html = "<span class='fileIcons docIcon'></span>";
						break;
					case ".docx":
						html = "<span class='fileIcons docxIcon'></span>";
						break;
					case ".xls":
						html = "<span class='fileIcons xlsIcon'></span>";
						break;
					case ".xlsx":
						html = "<span class='fileIcons xlsxIcon'></span>";
						break;
					case ".pdf":
						html = "<span class='fileIcons pdfIcon'></span>";
						break;
					case ".jpeg":
						html = "<span class='fileIcons jpegIcon'></span>";
						break;
					case ".jpg":
						html = "<span class='fileIcons jpgIcon'></span>";
						break;
					case ".bmp":
						html = "<span class='fileIcons bmpIcon'></span>";
						break;
					case ".png":
						html = "<span class='fileIcons pngIcon'></span>";
						break;
					case ".rar":
						html = "<span class='fileIcons rarIcon'></span>";
						break;
					default:
						html = "<span class='fileIcons normalIcon'></span>";
						break;
					}
				}
				var url = "<c:url value='/attchment/get/' />" + e.row.Id;
				e.cellHtml = html + "<a target='_blank' href='"+url+"'>"
						+ e.row.AttchmntName + "</a>";
			}
		}
		function setProjectLink(refNo,version){
			$.ajax({
				url : "<c:url value='/webpart/path/w20' />",
				type : "get",
				dataType : 'html',
				success : function(text) {
					var htmlStr = "<a class='aTagUnderLine' href='" + text
						+"/" + refNo +"/" + version 
						+ "' target='_blank' >[查看项目相关信息]</a>";
					parent.setProjectLink(htmlStr);
				},
				complete : function(XMLHttpRequest, textStatus) {
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
				}
			});
		}
		function onDrawGroup(e) {    
			var groupId = e.group.id;
        	var str = "版本：" + e.value;
        	if(groupId == 'g1'){
        		str += '（当前最新版本）';
        	}
        	e.cellHtml = str;
        }
		//判断显示机构还是个人信息
		function showOrgOrPer(){
			var val = mini.get("org_or_pers").getValue();
			if(val=="机构"){
				$("#org").html(orgInfo);
			}else if(val="个人"){
				$("#org").html(perInfo);
				$("#orgInfo").remove();
			}
			parent.contentFormOnload();
		}
		function continent(){
			var name= mini.get("country_area").getValue();
			$.ajax({
				url:"<c:url value='/common/continent'></c:url>",
				type:"post",
				dataType:"json",
				data:{"name":name},
				success:function(json){
					mini.get("area_range").setValue(json.zh_name);
				},
				complete : function(XMLHttpRequest, textStatus) {
					
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function continent1(){
			var name= mini.get("country_area1").getValue();
			$.ajax({
				url:"<c:url value='/common/continent'></c:url>",
				type:"post",
				dataType:"json",
				data:{"name":name},
				success:function(json){
					mini.get("area_range1").setValue(json.zh_name);
				},
				complete : function(XMLHttpRequest, textStatus) {
					
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
	</script>
</body>
</html>